package com.lw.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.lw.common.enums.GlobalTypeEnum;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.lw.entity.TbUserNotice;
import com.lw.mapper.TbUserNoticeMapper;
import com.lw.service.TbUserNoticeService;
import org.springframework.stereotype.Service;

import static com.lw.entity.table.TbUserNoticeTableDef.TB_USER_NOTICE;

/**
 * 用户通知公告表 服务层实现。
 *
 * @author lw
 * @since 2025年05月27日 18:09:06
 */
@Service
public class TbUserNoticeServiceImpl extends ServiceImpl<TbUserNoticeMapper, TbUserNotice>  implements TbUserNoticeService{

    @Override
    public Boolean readAll() {
        TbUserNotice tbUserNotice = new TbUserNotice();
        tbUserNotice.setIsRead(GlobalTypeEnum.NOTICE_READ.getValue());
        QueryWrapper queryWrapper = QueryWrapper.create();
        queryWrapper.eq(TB_USER_NOTICE.USER_ID.getName(),StpUtil.getLoginIdAsLong());
        queryWrapper.eq(TB_USER_NOTICE.IS_READ.getName(),GlobalTypeEnum.NOTICE_NO_READ.getValue());
        return this.update(tbUserNotice, queryWrapper);
    }
}
